<!--
选择计量单位
-->
<template>
  <a-select
      v-model:value="defaultValue"
      style="width: 100%"
      :options="options"
      :placeholder="placeholder"
      @change="onChange"
  ></a-select>
</template>
<script setup>
import { onMounted, ref, watch } from 'vue'
const emit = defineEmits(['change', 'update:value'])
const props = defineProps({
  value: {
    type: String,
    default: '件'
  },
  placeholder: {
    type: String,
    default: '请选择计量单位'
  }
})
const defaultValue = ref('')
const options = ref([
  { value: '件', label: '件' },
  { value: '个', label: '个' }
])
watch(() => props.value, (curr, old) => {
  defaultValue.value = curr
})
onMounted(() => {
  defaultValue.value = props.value
})
const onChange = (value,selectedOptions) => {
  emit('update:value', value)
}
</script>
<style scoped lang="scss">

</style>
